require(['./config'],()=>{
    require(['swiper','template','header','jqc'],(Swiper,template)=>{
        class Online {
            constructor () {
                this.getTabList()
                this.getLbList()
                this.getClassify1()
                this.getClassify2()
                this.getClassify3()
                this.getBanner1List().then(()=>{
                  this.banner()
                  this.user()
                })
                
            }
            banner () {
                //swiper是一个满足AMD规范的，所以在上面需要接受Swiper
                var mySwiper = new Swiper ('#banner1', {
                    loop: true, // 循环模式选项
                    autoplay:true,
                    autoplay: {
                      disableOnInteraction: false,
                    },
                    // 如果需要分页器
                    pagination: {
                      el: '#banner1 .swiper-pagination',
                    },
                    // 如果需要前进后退按钮
                    navigation: {
                      nextEl: '#banner1 .swiper-button-next',
                      prevEl: '#banner1 .swiper-button-prev',
                    }
                  })      
            }
            user () {
              console.log($.cookie('name'))
              if($.cookie('name')){
                $('#user span').html($.cookie('name'))
                $('#user').show()
                $('.LorR').hide()
              }
            }
            getBanner1List () {
              return new Promise((resolve,reject)=>{
                $.get('http://xiongmaoyouxuan.com/api/detail',{
                  id:40198520,
                  normal:1,
                  sa:''
                },resp=>{
                  console.log(resp)
                  if(resp.code==200){
                    let {descContentList} = resp.data.detail
                    // console.log(descContentList)
                    let list = descContentList.slice(6,10)
                    const html = template('banner1Template',{list})
                    $('#banner1List').html(html)
                    
                  }
                  resolve()
                })
              })
              
            }
            getLbList () {
              $.get('http://xiongmaoyouxuan.com/api/tabs',{
                sa:''
              },resp => {
                // console.log(resp)
                let {list} = resp.data
                list = list.slice(6,14)
                const html = template('lbTemplate',{list})
                $('#lbList').html(html)
              })
            }
            getTabList () {
              $.get('http://xiongmaoyouxuan.com/api/tab/11',{
                start:0
              },resp=>{
                // console.log(resp)
                if(resp.code=='200'){
                  // console.log(resp)
                  let {list} = resp.data.items
                  list = list.slice(0,)
                  const html = template('waterfallTemplate',{list})
                  $('#waterfallList').html(html)
                }
              })
            }
            getClassify1 () {
              $.get('http://xiongmaoyouxuan.com/api/tabs',{
                sa:''
              },resp => {
                // console.log(resp)
                let {list} = resp.data
                list = list.slice(1,8)
                const html = template('classifyTemplate1',{list})
                $('#classifyList1').html(html)
              })
            }
            getClassify2 () {
              $.get('http://xiongmaoyouxuan.com/api/tabs',{
                sa:''
              },resp => {
                // console.log(resp)
                let {list} = resp.data
                list = list.slice(7,14)
                const html = template('classifyTemplate2',{list})
                $('#classifyList2').html(html)
              })
            }
            getClassify3 () {
              $.get('http://xiongmaoyouxuan.com/api/tabs',{
                sa:''
              },resp => {
                // console.log(resp)
                let {list} = resp.data
                list = list.slice(3,7)
                const html = template('classifyTemplate3',{list})
                $('#classifyList3').html(html)
              })
            }
            
        }
        new Online()
    })
})